package com.tron.dobest.nettysocket;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

/**
 * 容器启动后执行方法
 * implements CommandLineRunner
 * implements ApplicationRunner
 */
//@Component
@Slf4j
public class TronNettySocketStart implements ApplicationRunner {

    private TronServerBootstrap tronServerBootstrap;

    @Value("${netty.ip}")
    private String ip;

    @Value("${netty.port}")
    private Integer port;


    public TronNettySocketStart(TronServerBootstrap tronServerBootstrap) {
        this.tronServerBootstrap = tronServerBootstrap;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("============WebSocketServer Start......============");
        tronServerBootstrap.start(ip,port);
    }
}
